package com.xbts.quartz.task;

import com.xbts.common.utils.StringUtils;
import com.xbts.system.mapper.SysUserMapper;
import com.xbts.system.module.payment.service.ICnWalletLogService;
import com.xbts.system.service.*;
import com.xbts.system.service.impl.CnRegionServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定时任务调度测试
 *
 * @author xbts
 */
@Slf4j
@Component("ryTask")
public class RyTask {

    @Autowired
    private CnRegionServiceImpl cnRegionServiceImpl;
    @Autowired
    private ICnBalanceOrderService cnBalanceOrderService;

    @Autowired
    private ICnUserCloudServersRelationService cnUserCloudServersRelationService;
    @Autowired
    private SysUserMapper userMapper;
    @Autowired
    private ISmsService smsService;
    @Autowired
    private ICnOrderService cnOrderService;
    @Autowired
    private ICnOrderItemService cnOrderItemService;
    @Autowired
    private ICnWalletLogService cnWalletLogService;
    @Autowired
    private ICloudControlService cloudControlService;



    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
        System.out.println("执行无参方法");
    }

    /**
     * 更新不存在的规格任务
     */
    public void updateFlavor() {
        cnRegionServiceImpl.initRegionMap();
        log.debug("每日更新不存在的规格任务");
    }

    /**
     * 余额订单超时任务(弃用)
     */
    public void orderTimeout() {
//        cnBalanceOrderService.cancelTimeoutOrder();
        log.debug("余额订单超时任务");
    }

    /**
     * 自动续费任务
     */
    public void autoRenewTask() {
        AutoRenewTask autoRenewTask = new AutoRenewTask();
        autoRenewTask.autoRenew(cnUserCloudServersRelationService, userMapper, smsService, cnOrderService,
                cnOrderItemService,cnWalletLogService);
        log.debug("自动续费任务");
    }


    /**
     * 将过期服务器状态改为已过期, 定时查询服务器状态
     */
    public void expirationAutoRenew() {
        AutoRenewTask autoRenewTask = new AutoRenewTask();
        autoRenewTask.expirationAutoRenew(cnUserCloudServersRelationService, cloudControlService);
        log.debug("将过期服务器状态改为已过期");
    }
}
